Paren-free PHP? [on hold]
Posted
by
Ivan Curdinjakovic
on Programmers
See other posts from Programmers
or by Ivan Curdinjakovic
Published on 2013-11-12T07:04:48Z
Indexed on
2013/11/12
10:20 UTC
Read the original article
Hit count: 232
I stumbled upon the idea for paren-free ecmascript (https://brendaneich.com/2010/11/paren-free/), which is inspired by Go language.
And it's simple, clean and cool - if you make braces required instead of recommended (and they are recommended everywhere anyway: http://www.php-fig.org/psr/psr-2/), then parenthesis are unneeded around control structure “heads”. It would work exactly the same in PHP. So, a piece of PHP code could look like this:
if $someVar == 42 {
doSomething();
}
or:
foreach $someArray as $key => $value {
echo "$key: $value";
}
It's a small, but nice step towards a nicer, cleaner syntax and removing unnecessary parts. The question is - would PHP community be willing to see the languange move in that direction? Would it be considered an improvement by majority, or are we too used to typing those parenthesis and unwilling to see any change in PHP syntax?
© Programmers or respective owner